<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class RBS::Writer - rbs: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-attribute">#attribute</a>
    <li ><a href="#method-i-format_annotation">#format_annotation</a>
    <li ><a href="#method-i-indent">#indent</a>
    <li ><a href="#method-i-method_name">#method_name</a>
    <li ><a href="#method-i-name_and_args">#name_and_args</a>
    <li ><a href="#method-i-name_and_params">#name_and_params</a>
    <li ><a href="#method-i-prefix">#prefix</a>
    <li ><a href="#method-i-preserve-21">#preserve!</a>
    <li ><a href="#method-i-preserve-3F">#preserve?</a>
    <li ><a href="#method-i-preserve_empty_line">#preserve_empty_line</a>
    <li ><a href="#method-i-put_lines">#put_lines</a>
    <li ><a href="#method-i-puts">#puts</a>
    <li ><a href="#method-i-write">#write</a>
    <li ><a href="#method-i-write_annotation">#write_annotation</a>
    <li ><a href="#method-i-write_comment">#write_comment</a>
    <li ><a href="#method-i-write_decl">#write_decl</a>
    <li ><a href="#method-i-write_def">#write_def</a>
    <li ><a href="#method-i-write_directive">#write_directive</a>
    <li ><a href="#method-i-write_loc_source">#write_loc_source</a>
    <li ><a href="#method-i-write_member">#write_member</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-RBS::Writer">
    <h1 id="class-RBS::Writer" class="class">
      class RBS::Writer
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-indentation" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">indentation</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-out" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">out</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(out:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-value">out:</span>)
  <span class="ruby-ivar">@out</span> = <span class="ruby-identifier">out</span>
  <span class="ruby-ivar">@indentation</span> = []
  <span class="ruby-ivar">@preserve</span> = <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-attribute" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">attribute</span><span
                                class="method-args">(kind, attr)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="attribute-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 361</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">attribute</span>(<span class="ruby-identifier">kind</span>, <span class="ruby-identifier">attr</span>)
  <span class="ruby-identifier">visibility</span> =
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">visibility</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:public</span>
      <span class="ruby-string">&quot;public &quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:private</span>
      <span class="ruby-string">&quot;private &quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">var</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">ivar_name</span>
        <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
          <span class="ruby-string">&quot;&quot;</span>
        <span class="ruby-keyword">when</span> <span class="ruby-keyword">false</span>
          <span class="ruby-string">&quot;()&quot;</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-node">&quot;(#{attr.ivar_name})&quot;</span>
        <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">receiver</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">kind</span>
             <span class="ruby-keyword">when</span> <span class="ruby-value">:singleton</span>
               <span class="ruby-string">&quot;self.&quot;</span>
             <span class="ruby-keyword">when</span> <span class="ruby-value">:instance</span>
               <span class="ruby-string">&quot;&quot;</span>
             <span class="ruby-keyword">end</span>

  <span class="ruby-node">&quot;#{visibility}attr_#{kind} #{receiver}#{attr.name}#{var}: #{attr.type}&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-format_annotation" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">format_annotation</span><span
                                class="method-args">(annotation)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="format_annotation-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 42</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">format_annotation</span>(<span class="ruby-identifier">annotation</span>)
  <span class="ruby-identifier">string</span> = <span class="ruby-identifier">annotation</span>.<span class="ruby-identifier">string</span>
  <span class="ruby-keyword">case</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">string</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/\}/</span>
    <span class="ruby-node">&quot;%a{#{string}}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">string</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/\)/</span>
    <span class="ruby-node">&quot;%a(#{string})&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">string</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/\]/</span>
    <span class="ruby-node">&quot;%a[#{string}]&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">string</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/\&gt;/</span>
    <span class="ruby-node">&quot;%a&lt;#{string}&gt;&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-identifier">string</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/\|/</span>
    <span class="ruby-node">&quot;%a|#{string}|&quot;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-indent" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">indent</span><span
                                class="method-args">(size = 2) { || ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="indent-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 23</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">indent</span>(<span class="ruby-identifier">size</span> = <span class="ruby-value">2</span>)
  <span class="ruby-identifier">indentation</span>.<span class="ruby-identifier">push</span>(<span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">size</span>)
  <span class="ruby-keyword">yield</span>
<span class="ruby-keyword">ensure</span>
  <span class="ruby-identifier">indentation</span>.<span class="ruby-identifier">pop</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-method_name" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">method_name</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="method_name-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 288</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method_name</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">s</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">s</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A(_?)[A-Za-z_]\w*(\?|!|=)?\Z/</span>
    <span class="ruby-identifier">s</span>
  <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-node">%w(|  ^  &amp;  &lt;=&gt;  ==  ===  =~  &gt;   &gt;=  &lt;   &lt;=   &lt;&lt;  &gt;&gt; +  -  *  /  %   **   ~   +@  -@  []  []=  ` ! != !~)</span>
    <span class="ruby-identifier">s</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-node">&quot;`#{s}`&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-name_and_args" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">name_and_args</span><span
                                class="method-args">(name, args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="name_and_args-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 214</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">name_and_args</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">args</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-node">&quot;#{name}&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-node">&quot;#{name}[#{args.join(&quot;, &quot;)}]&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-name_and_params" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">name_and_params</span><span
                                class="method-args">(name, params)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="name_and_params-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 202</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">name_and_params</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">params</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-node">&quot;#{name}&quot;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">ps</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">param</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-node">&quot;#{name}[#{ps.join(&quot;, &quot;)}]&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prefix" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">prefix</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="prefix-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 30</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">prefix</span>
  <span class="ruby-identifier">indentation</span>.<span class="ruby-identifier">join</span>()
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-preserve-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">preserve!</span><span
                                class="method-args">(preserve: true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="preserve-21-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 18</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">preserve!</span>(<span class="ruby-value">preserve:</span> <span class="ruby-keyword">true</span>)
  <span class="ruby-ivar">@preserve</span> = <span class="ruby-identifier">preserve</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-preserve-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">preserve?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="preserve-3F-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 14</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">preserve?</span>
  <span class="ruby-ivar">@preserve</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-preserve_empty_line" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">preserve_empty_line</span><span
                                class="method-args">(prev, decl)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="preserve_empty_line-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 391</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">preserve_empty_line</span>(<span class="ruby-identifier">prev</span>, <span class="ruby-identifier">decl</span>)
  <span class="ruby-comment"># @type var decl: _Located</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">prev</span>

  <span class="ruby-keyword">if</span> (<span class="ruby-identifier">_</span> = <span class="ruby-identifier">decl</span>).<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:comment</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">comment</span> = (<span class="ruby-identifier">_</span> = <span class="ruby-identifier">decl</span>).<span class="ruby-identifier">comment</span>
      <span class="ruby-identifier">decl</span> = <span class="ruby-identifier">comment</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">prev_loc</span> = <span class="ruby-identifier">prev</span>.<span class="ruby-identifier">location</span>
  <span class="ruby-identifier">decl_loc</span> = <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">prev_loc</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">decl_loc</span>
    <span class="ruby-identifier">prev_end_line</span> = <span class="ruby-identifier">prev_loc</span>.<span class="ruby-identifier">end_line</span>
    <span class="ruby-identifier">start_line</span> = <span class="ruby-identifier">decl_loc</span>.<span class="ruby-identifier">start_line</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">start_line</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">prev_end_line</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
      <span class="ruby-identifier">puts</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-comment"># When the signature is not constructed by the parser,</span>
    <span class="ruby-comment"># it always inserts an empty line.</span>
    <span class="ruby-identifier">puts</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-put_lines" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">put_lines</span><span
                                class="method-args">(lines, leading_spaces:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="put_lines-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 224</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">put_lines</span>(<span class="ruby-identifier">lines</span>, <span class="ruby-value">leading_spaces:</span>)
  <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">each_line</span>.<span class="ruby-identifier">with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp!</span>
    <span class="ruby-identifier">line</span>.<span class="ruby-identifier">rstrip!</span>
    <span class="ruby-identifier">line</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/\A( {,#{leading_spaces}})/</span>, <span class="ruby-string">&#39;&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">index</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>

    <span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-puts" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">puts</span><span
                                class="method-args">(string = &quot;&quot;)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="puts-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 34</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">puts</span>(<span class="ruby-identifier">string</span> = <span class="ruby-string">&quot;&quot;</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
    <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-node">&quot;#{prefix}#{string}&quot;</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">puts</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write</span><span
                                class="method-args">(contents)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 79</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write</span>(<span class="ruby-identifier">contents</span>)
  <span class="ruby-identifier">dirs</span> = <span class="ruby-identifier">contents</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Directives</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>) } <span class="ruby-comment">#: Array[AST::Directives::t]</span>
  <span class="ruby-identifier">decls</span> = <span class="ruby-identifier">contents</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>) } <span class="ruby-comment">#: Array[AST::Declarations::t]</span>

  <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">write_directive</span>(<span class="ruby-identifier">dir</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">puts</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">empty?</span>

  [<span class="ruby-keyword">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">decls</span>].<span class="ruby-identifier">each_cons</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">prev</span>, <span class="ruby-identifier">decl</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">decl</span>

    <span class="ruby-identifier">preserve_empty_line</span>(<span class="ruby-identifier">prev</span>, <span class="ruby-identifier">decl</span>)
    <span class="ruby-identifier">write_decl</span> <span class="ruby-identifier">decl</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_annotation" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_annotation</span><span
                                class="method-args">(annotations)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write_annotation-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 60</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_annotation</span>(<span class="ruby-identifier">annotations</span>)
  <span class="ruby-identifier">annotations</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">annotation</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-identifier">format_annotation</span>(<span class="ruby-identifier">annotation</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_comment" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_comment</span><span
                                class="method-args">(comment)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write_comment-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 66</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_comment</span>(<span class="ruby-identifier">comment</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">comment</span>.<span class="ruby-identifier">string</span>.<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">line</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">empty?</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;# #{line}&quot;</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;#&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_decl" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_decl</span><span
                                class="method-args">(decl)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write_decl-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 114</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_decl</span>(<span class="ruby-identifier">decl</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">decl</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">Class</span>
    <span class="ruby-identifier">super_class</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">super_class</span> = <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">super_class</span>
                    <span class="ruby-node">&quot; &lt; #{name_and_args(super_class.name, super_class.args)}&quot;</span>
                  <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;class #{name_and_params(decl.name, decl.type_params)}#{super_class}&quot;</span>

    <span class="ruby-identifier">indent</span> <span class="ruby-keyword">do</span>
      [<span class="ruby-keyword">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">decl</span>.<span class="ruby-identifier">members</span>].<span class="ruby-identifier">each_cons</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">prev</span>, <span class="ruby-identifier">member</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">member</span>

        <span class="ruby-identifier">preserve_empty_line</span> <span class="ruby-identifier">prev</span>, <span class="ruby-identifier">member</span>
        <span class="ruby-identifier">write_member</span> <span class="ruby-identifier">member</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;end&quot;</span>

  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">Module</span>
    <span class="ruby-identifier">self_type</span> = <span class="ruby-keyword">unless</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">self_types</span>.<span class="ruby-identifier">empty?</span>
                  <span class="ruby-node">&quot; : #{decl.self_types.join(&quot;, &quot;)}&quot;</span>
                <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">annotations</span>

    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;module #{name_and_params(decl.name, decl.type_params)}#{self_type}&quot;</span>

    <span class="ruby-identifier">indent</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">members</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">member</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">index</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
          <span class="ruby-identifier">puts</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">write_member</span> <span class="ruby-identifier">member</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;end&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">Constant</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{decl.name}: #{decl.type}&quot;</span>

  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">Global</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{decl.name}: #{decl.type}&quot;</span>

  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeAlias</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">write_loc_source</span>(<span class="ruby-identifier">decl</span>) {
      <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;type #{name_and_params(decl.name, decl.type_params)} = #{decl.type}&quot;</span>
    }

  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassAlias</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_loc_source</span>(<span class="ruby-identifier">decl</span>) {
      <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;class #{decl.new_name} = #{decl.old_name}&quot;</span>
    }

  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">ModuleAlias</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_loc_source</span>(<span class="ruby-identifier">decl</span>) {
      <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;module #{decl.new_name} = #{decl.old_name}&quot;</span>
    }

  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">Interface</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">annotations</span>

    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;interface #{name_and_params(decl.name, decl.type_params)}&quot;</span>

    <span class="ruby-identifier">indent</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">members</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">member</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">index</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
          <span class="ruby-identifier">puts</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">write_member</span> <span class="ruby-identifier">member</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;end&quot;</span>

  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_def" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_def</span><span
                                class="method-args">(member)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write_def-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 309</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_def</span>(<span class="ruby-identifier">member</span>)
  <span class="ruby-identifier">visibility</span> =
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">visibility</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:public</span>
      <span class="ruby-string">&quot;public &quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:private</span>
      <span class="ruby-string">&quot;private &quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">name</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">kind</span>
         <span class="ruby-keyword">when</span> <span class="ruby-value">:instance</span>
           <span class="ruby-node">&quot;#{method_name(member.name)}&quot;</span>
         <span class="ruby-keyword">when</span> <span class="ruby-value">:singleton_instance</span>
           <span class="ruby-node">&quot;self?.#{method_name(member.name)}&quot;</span>
         <span class="ruby-keyword">when</span> <span class="ruby-value">:singleton</span>
           <span class="ruby-node">&quot;self.#{method_name(member.name)}&quot;</span>
         <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">string</span> = <span class="ruby-string">+&quot;&quot;</span>

  <span class="ruby-identifier">prefix</span> = <span class="ruby-node">&quot;#{visibility}def #{name}:&quot;</span>
  <span class="ruby-identifier">padding</span> = <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">*</span> (<span class="ruby-identifier">prefix</span>.<span class="ruby-identifier">size</span><span class="ruby-value">-1</span>)

  <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">prefix</span>

  <span class="ruby-identifier">member</span>.<span class="ruby-identifier">overloads</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">overload</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">index</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
      <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">padding</span>
      <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;|&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">overload</span>.<span class="ruby-identifier">annotations</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">annotation</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; #{format_annotation(annotation)}&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; #{overload.method_type}\n&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">overloading?</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">overloads</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
      <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">padding</span>
      <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;|&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot; ...\n&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">string</span>.<span class="ruby-identifier">each_line</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_directive" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_directive</span><span
                                class="method-args">(dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write_directive-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 97</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_directive</span>(<span class="ruby-identifier">dir</span>)
  <span class="ruby-identifier">clauses</span> = <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">clauses</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">clause</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">clause</span>
    <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Directives</span><span class="ruby-operator">::</span><span class="ruby-constant">Use</span><span class="ruby-operator">::</span><span class="ruby-constant">SingleClause</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">clause</span>.<span class="ruby-identifier">new_name</span>
        <span class="ruby-node">&quot;#{clause.type_name} as #{clause.new_name}&quot;</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-node">&quot;#{clause.type_name}&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Directives</span><span class="ruby-operator">::</span><span class="ruby-constant">Use</span><span class="ruby-operator">::</span><span class="ruby-constant">WildcardClause</span>
      <span class="ruby-node">&quot;#{clause.namespace}*&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  
  <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;use #{clauses.join(&quot;, &quot;)}&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_loc_source" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_loc_source</span><span
                                class="method-args">(located) { || ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write_loc_source-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 301</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_loc_source</span>(<span class="ruby-identifier">located</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">loc</span> = <span class="ruby-identifier">located</span>.<span class="ruby-identifier">location</span>
    <span class="ruby-identifier">put_lines</span>(<span class="ruby-identifier">loc</span>.<span class="ruby-identifier">source</span>, <span class="ruby-value">leading_spaces:</span> <span class="ruby-identifier">loc</span>.<span class="ruby-identifier">start_column</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">yield</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write_member" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write_member</span><span
                                class="method-args">(member)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="write_member-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/writer.rb, line 234</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_member</span>(<span class="ruby-identifier">member</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Include</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;include #{name_and_args(member.name, member.args)}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Extend</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;extend #{name_and_args(member.name, member.args)}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Prepend</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;prepend #{name_and_args(member.name, member.args)}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrAccessor</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{attribute(:accessor, member)}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrReader</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{attribute(:reader, member)}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrWriter</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{attribute(:writer, member)}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Public</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;public&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Private</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;private&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Alias</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">new_name</span> = <span class="ruby-identifier">member</span>.<span class="ruby-identifier">singleton?</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;self.#{member.new_name}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">new_name</span>
    <span class="ruby-identifier">old_name</span> = <span class="ruby-identifier">member</span>.<span class="ruby-identifier">singleton?</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;self.#{member.old_name}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">old_name</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;alias #{new_name} #{old_name}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceVariable</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{member.name}: #{member.type}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassInstanceVariable</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;self.#{member.name}: #{member.type}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassVariable</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{member.name}: #{member.type}&quot;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">MethodDefinition</span>
    <span class="ruby-identifier">write_comment</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">comment</span>
    <span class="ruby-identifier">write_annotation</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">annotations</span>
    <span class="ruby-identifier">write_loc_source</span>(<span class="ruby-identifier">member</span>) { <span class="ruby-identifier">write_def</span> <span class="ruby-identifier">member</span> }
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">write_decl</span> <span class="ruby-identifier">member</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

